package entertainmentguide.entity;

import java.util.StringTokenizer;
/**
 *
 * 
 */
public class Area {
    private int areaId;
    private String areaName;

    public Area(int areaId, String areaName) {
        this.areaId = areaId;
        this.areaName = areaName;
    }

    public Area() {
        this.areaId=0; 
    }

    public void setAreaId(int areaId) {
        this.areaId = areaId;
    }

    public int getAreaId() {
        return areaId;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public String getAreaName() {
        return areaName;
    }

    @Override
    public String toString(){
        return  "\n" + " | " + "ID: " + getAreaId() + " | " +
                "Όνομα: " + getAreaName() + " | ";
    }

    /**
     * Creates an Area object by parsing line.
     * The line must be in the following format:
     * AREA: <restId> <areaName>
     *
     * @param line
     * @return
     */
    public static Area parseArea(String line) throws IllegalArgumentException{
        StringTokenizer strTok = new StringTokenizer(line);
        String s1 = strTok.nextToken(); // Area:
        String s2 = strTok.nextToken(); // areaId
        String s3 = strTok.nextToken(); // areaName
        strTok.nextToken("\""); //Skip the first toker with "

        int d2 = Integer.parseInt(s2);

        return new Area(d2,s3);
    }

}
